<?php

function show_header() {
    require('./admin/connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $ts_ip = $line_info['tsip_info'];
    $ts_port = $line_info['tsport_info'];
    $mumble_ip = $line_info['mumbleip_info'];
    $mumble_port = $line_info['mumbleport_info'];

    $host = $line_info['serverip_info'];
    $port = $line_info['serverport_info'];
    ?>
    <div class="header">
        <div class="headerbg">
            <div class="wrapper">
                <div class="userbar">
                    <div class="left">
                        <div class="dline px11">
                            <strong>Serveur Minecraft :</strong>
                        </div>
                        <?php
                        if ($ts_ip && $ts_port != "") {
                            ?>
                            <div class="dline px11">
                                <strong>TeamSpeak 3 :</strong>
                            </div>
                            <?php
                        } else if ($mumble_ip && $mumble_port != "") {
                            ?>
                            <div class="dline px11">
                                <strong>Mumble :</strong>
                            </div>
                            <?php
                        } else {
                            ?>
                            <div class="dline px11">
                                <strong>Port :</strong>
                            </div>
                            <?php
                        }
                        ?>
                        <div class="dline px11">
                            <strong>&Eacute;tat du serveur :</strong>
                        </div>
                    </div>
                    <div class="right">
                        <div class="dline">
                            <?php echo $host; ?>
                        </div>
                        <?php
                        if ($ts_ip && $ts_port != "") {
                            ?>
                            <div class="dline">
                                <a href="ts3server://<?php echo $ts_ip; ?>?port=<?php echo $ts_port; ?>" class="white" title="Cliquez pour lancez TS3 et automatiquement vous connectez &agrave; notre serveur."><?php echo $ts_ip . ":" . $ts_port; ?></a>
                            </div>
                            <?php
                        } else if ($mumble_ip && $mumble_port != "") {
                            ?>
                            <div class="dline">
                                <?php echo $mumble_ip . ":" . $mumble_port; ?>
                            </div>
                            <?php
                        } else {
                            ?>
                            <div class="dline">
                                <?php echo $port; ?>
                            </div>
                            <?php
                        }
                        ?>
                        <div class="etat">
                            <?php
                            $server['name'] = "Srv1";
                            $server['host'] = $host;
                            $server['port'] = $port;
                            $connection = @fsockopen($server['host'], $server['port'], $ERROR_NO, $ERROR_STR, (float) 1.5);

                            if ($connection) {
                                fclose($connection);
                                echo "<img src='./images/icone/online.png' class='etat' />";
                            } else {
                                echo "<img src='./images/icone/offline.png' class='etat' />";
                            }
                            ?>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="logo transparent"><a href="./"></a></div>
            </div>
        </div>
    </div>
    <?php
}

function show_header_adm() {
    require('./connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $ts_ip = $line_info['tsip_info'];
    $ts_port = $line_info['tsport_info'];
    $mumble_ip = $line_info['mumbleip_info'];
    $mumble_port = $line_info['mumbleport_info'];

    $host = $line_info['serverip_info'];
    $port = $line_info['serverport_info'];
    ?>
    <div class="header">
        <div class="headerbg">
            <div class="wrapper">
                <div class="userbar">
                    <div class="left">
                        <div class="dline px11">
                            <strong>Serveur Minecraft :</strong>
                        </div>
                        <?php
                        if ($ts_ip && $ts_port != "") {
                            ?>
                            <div class="dline px11">
                                <strong>TeamSpeak 3 :</strong>
                            </div>
                            <?php
                        } else if ($mumble_ip && $mumble_port != "") {
                            ?>
                            <div class="dline px11">
                                <strong>Mumble :</strong>
                            </div>
                            <?php
                        } else {
                            ?>
                            <div class="dline px11">
                                <strong>Port :</strong>
                            </div>
                            <?php
                        }
                        ?>
                        <div class="dline px11">
                            <strong>&Eacute;tat du serveur :</strong>
                        </div>
                    </div>
                    <div class="right">
                        <div class="dline">
                            <?php echo $host; ?>
                        </div>
                        <?php
                        if ($ts_ip && $ts_port != "") {
                            ?>
                            <div class="dline">
                                <a href="ts3server://<?php echo $ts_ip; ?>?port=<?php echo $ts_port; ?>" class="white" title="Cliquez pour lancez TS3 et automatiquement vous connectez &agrave; notre serveur."><?php echo $ts_ip . ":" . $ts_port; ?></a>
                            </div>
                            <?php
                        } else if ($mumble_ip && $mumble_port != "") {
                            ?>
                            <div class="dline">
                                <?php echo $mumble_ip . ":" . $mumble_port; ?>
                            </div>
                            <?php
                        } else {
                            ?>
                            <div class="dline">
                                <?php echo $port; ?>
                            </div>
                            <?php
                        }
                        ?>
                        <div class="etat">
                            <?php
                            $server['name'] = "Srv1";
                            $server['host'] = $host;
                            $server['port'] = $port;
                            $connection = @fsockopen($server['host'], $server['port'], $ERROR_NO, $ERROR_STR, (float) 1.5);

                            if ($connection) {
                                fclose($connection);
                                echo "<img src='../images/icone/online.png' class='etat' />";
                            } else {
                                echo "<img src='../images/icone/offline.png' class='etat' />";
                            }
                            ?>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="logo transparent"><a href="./"></a></div>
            </div>
        </div>
    </div>
    <?php
}

function show_menu() {
    require('./admin/connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $query_plugins = "SELECT * FROM " . $database . "." . $tb_plugins . "";
    $result_plugins = @mysql_query($query_plugins) OR DIE("Erreur de la s&eacute;lection des news : " . mysql_error());
    $line_plugins = mysql_fetch_assoc($result_plugins);

    $ts_ip = $line_info['tsip_info'];
    $ts_port = $line_info['tsport_info'];
    $mumble_ip = $line_info['mumbleip_info'];
    $mumble_port = $line_info['mumbleport_info'];

    $host = $line_info['serverip_info'];
    $port = $line_info['serverport_info'];

    $forum = $line_info['forum_info'];
    $map = $line_info['dynmap_info'];
    $live = $line_info['live_info'];
    $youtube = $line_info['youtube_info'];
    ?>
    <div class="mainmenu">
        <div class="wrapper">
            <div class="left content mainlinks">
                <ul class="menu">
                    <li class="top">
                        <a href="./" target="_self" class="top_link"><span>Accueil</span></a>
                    </li>
                    <?php
                    if ($forum != "") {
                        ?>
                        <li class="top">
                            <a href="<?php echo $forum; ?>" target="_blank" class="top_link"><span>Forum</span></a>
                        </li>
                        <?php
                    }
                    if ($map != "" && $line_plugins['dynmap_plg'] == "Oui") {
                        ?>
                        <li class="top">
                            <a href="<?php echo $map; ?>" target="_blank" class="top_link"><span>Map</span></a>
                        </li>
                        <?php
                    }
                    if ($live != "") {
                        ?>
                        <li class="top">
                            <a href="<?php echo $live; ?>" target="_blank"  class="top_link" title="Suivez-nous en direct !"><span>Live</span></a>
                        </li>
                        <?php
                    } else if ($youtube != "") {
                        ?>
                        <li class="top">
                            <a href="<?php echo $youtube; ?>" target="_blank" class="top_link" title="Notre cha&icirc;ne Youtube"><span>YouTube</span></a>
                        </li>
                        <?php
                    }
                    ?>
                    <li class="top">
                        <a href="./help.php" target="_self" class="top_link" title="Besoin d'aide ?"><span>Trucs & astuces</span></a>
                        <ul class="sub">
                            <li><a href="./texture.php" target="_self" title="Comment ajouter un pack de texture ?">Installer une nouvelle Texture</a></li>
                            <li><a href="./java.php" target="_self">R&eacute;soudre le probl&egrave;me d'&eacute;cran noir</a></li>
                            <li><a href="./help.php?plugin=lockette" target="_self">S&eacute;curiser son coffre</a></li>
                        </ul>
                    </li>
                    <li class="top">
                        <a href="./galerie.php" target="_self" class="top_link" title="Visionner la galerie d'images"><span>Galerie</span></a>
                    </li>
                    <li class="top">
                        <a href="./faq.php" target="_self" class="top_link" title="Consulter la Foire Aux Questions"><span>F.A.Q.</span></a>
                    </li>
                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <?php
}

function show_menu_adm() {
    require('./connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $query_plugins = "SELECT * FROM " . $database . "." . $tb_plugins . "";
    $result_plugins = @mysql_query($query_plugins) OR DIE("Erreur de la s&eacute;lection des news : " . mysql_error());
    $line_plugins = mysql_fetch_assoc($result_plugins);

    $forum = $line_info['forum_info'];
    $map = $line_info['dynmap_info'];

    $datalog = $line_plugins['datalog_plg'];
    $iconomy = $line_plugins['iconomy_plg'];
    $jobs = $line_plugins['jobs_plg'];
    $dynmap = $line_plugins['dynmap_plg'];
    ?>
    <div class="mainmenu">
        <div class="wrapper">
            <div class="left content mainlinks">
                <ul class="menu">
                    <li class="top">
                        <a href="../" target="_self" class="top_link"><span>Voir le site</span></a>
                    </li>
                    <li class="top">
                        <a href="./accueil.php" target="_self" class="top_link"><span>Gestion du site</span></a>
                        <ul class="sub">
                            <li><a href="./site.php" target="_self">Configuration du site</a></li>
                            <li><a href="./plugins.php" target="_self">Gestion des plugins</a></li>
                            <li><a href="./maintenance.php" target="_self">Gestion de la maintenance</a></li>
                            <li><a href="./annonce.php" target="_self">Gestion des annonces</a></li>
                            <li><a href="./news.php" target="_self">Gestion des news</a></li>
                            <li><a href="./admin.php" target="_self">Gestion des utilisateurs</a></li>
                            <li><a href="./comment.php" target="_self">Gestion des commentaires</a></li>
                            <li><a href="./mp.php" target="_self">Gestion des MP's</a></li>
                            <li><a href="./faq.php" target="_self">Gestion de la F.A.Q.</a></li>
                            <li><a href="./team.php" target="_self">Gestion de "l'&eacute;quipe"</a></li>
                            <?php
                            if ($forum != "") {
                                ?>
                                <li><a href="<?php echo $forum; ?>" target="_blank">Acc&egrave;der du forum</a></li>
                                <?php
                            }
                            ?>
                        </ul>
                    </li>
                    <?php
                    if ($datalog == "Oui" || $iconomy == "Oui" || $jobs == "Oui") {
                        ?>
                        <li class="top">
                            <a href="./accueil.php" target="_self" class="top_link"><span>Gestion du serveur</span></a>
                            <ul class="sub">
                                <?php
                                if ($datalog == "Oui") {
                                    ?>
                                    <li><a href="./log.php" target="_self">Gestion des logs</a></li>
                                    <?php
                                }
                                if ($iconomy == "Oui") {
                                    ?>
                                    <li><a href="./iconomy.php" target="_self">Gestion de l'&eacute;conomie</a></li>
                                    <?php
                                }
                                if ($jobs == "Oui") {
                                    ?>
                                    <li><a href="./jobs.php" target="_self">Gestion des Jobs</a></li>
                                    <?php
                                }
                                ?>
                            </ul>
                        </li>
                        <?php
                    }
                    if ($map != "" && $dynmap == "Oui") {
                        ?>
                        <li class="top">
                            <a href="<?php echo $map; ?>" target="_blank" class="top_link"><span>Map</span></a>
                        </li>
                        <?php
                    }
                    ?>
                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <?php
}

function show_newsbox() {
    ?>
    <div class="newsbox">
        <div id="news">
            <div id="liens">
                <div id="newsI1" onClick="changeNews(1)"></div>
                <div id="newsI2" onClick="changeNews(2)"></div>
                <div id="newsI3" onClick="changeNews(3)"></div>
            </div>

            <div id="news1" onClick="location.href = './galerie.php';"></div>
            <div id="news2" onClick="location.href = './galerie.php';"></div>
            <div id="news3" onClick="location.href = './galerie.php';"></div>
        </div>
    </div>
    <?php
}

function show_userbox() {
    ?>
    <?php
    if (@session_is_registered("authentification")) { // Affichage conditionnel : si et seulement si l'utilisateur est connect&eacute; avec le privilege utilisateur simple
        ?>
        <div class="userbox">
            <div class="userbox_left left white">Bienvenue &agrave; toi <b><a href="./profil.php" class="mainlinks white" title="Voir mon profil"><?php echo $_SESSION['login']; ?></a></b>&nbsp;<a href="./login.php?erreur=logout" class="mainlinks white" title="Vous d&eacute;connectez"><b class="white">[</b> D&eacute;connexion <b class="white">]</b></a></div>
            <div class="userbox_right right white"><a href="./profil.php" class="mainlinks white" title="G&eacute;rer mon profil"><b>Mon Profil</b></a>&nbsp;-&nbsp;<a href="./message.php" class="mainlinks white" title="Voir mes messages priv&eacute;s"><b>Bo&icirc;te de r&eacute;ception</b></a>&nbsp;-&nbsp;<a href="./membres.php" class="mainlinks white" title="Consulter la liste des membres"><b>Liste des membres</b></a></div>
        </div>
        <?php
    } else {
        ?>
        <div class="userbox">
            <div class="userbox_left left white">Bienvenue &agrave; toi <b>Visiteur</b></div>
            <div class="userbox_right right white"><a href="./login.php" class="mainlinks white"><b>Connexion</b></a>&nbsp;-&nbsp;<a href="./register.php" class="mainlinks white"><b>Inscription</b></a></div>
        </div>
        <?php
    }
    ?>

    <?php
}

function show_footer() {
    require('./admin/connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $site = $line_info['sitename_info'];
    $facebook = $line_info['facebook_info'];
    ?>
    <div class="footer">
        <div class="left content">
            <span class="ltr">&copy; <a href="./admin/" class="tooltip" title="Tous Droits R&eacute;serv&eacute;s"><?php echo $site; ?></a> | 2011 | <a href="http://www.facebook.com/pages/Fujido/129154603839560" title="Page Facebook">Fujido</a> | <a href="./about.php" title="Informations">&Agrave; propos</a> | <a href="./team.php" title="L'&eacute;quipe du serveur">L'&eacute;quipe</a>
                <span class="footer_right">
                    <a href="http://www.mcfr.in/" title="Classement Minecraft Neutre - MCFR" target="_BLANK"><img alt="Classement Minecraft Neutre" src="./images/icone/mcfr.png" /></a>
                    <?php
                    if ($facebook != "") {
                        ?>
                        &nbsp;
                        <a href="<?php echo $facebook; ?>" title="Facebook" target="_BLANK"><img src="./images/icone/facebook.png" alt="Facebook" /></a>
                    <?php } ?>
                </span>
            </span>
        </div>
        <div class="clear"></div>
    </div>
    <?php
}

function show_footer_adm() {
    require('./connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $site = $line_info['sitename_info'];
    $facebook = $line_info['facebook_info'];
    ?>
    <div class="footer">
        <div class="left content">
            <span class="ltr">&copy; <a href="./admin/" class="tooltip" title="Tous Droits R&eacute;serv&eacute;s"><?php echo $site; ?></a> | 2011 | <a href="http://www.facebook.com/pages/Fujido/129154603839560" title="Page Facebook">Fujido</a> | <a href="../about.php" title="Informations">&Agrave; propos</a> | <a href="../team.php" title="L'&eacute;quipe du serveur">L'&eacute;quipe</a>
                <span class="footer_right">
                    <a href="http://www.mcfr.in/" title="Classement Minecraft Neutre - MCFR" target="_BLANK"><img alt="Classement Minecraft Neutre" src="../images/icone/mcfr.png" /></a>
                    <?php
                    if ($facebook != "") {
                        ?>
                        &nbsp;
                        <a href="<?php echo $facebook; ?>" title="Facebook" target="_BLANK"><img src="../images/icone/facebook.png" alt="Facebook" /></a>
                    <?php } ?>
                </span>
            </span>
        </div>
        <div class="clear"></div>
    </div>
    <?php
}

function displayAll() {
    require('./admin/connexion.php');

    $limite = 5;

    $template = "./news/templates/template_news_fr.php";
    //Connexion au serveur
    @mysql_connect($hostname, $username, $password) OR DIE("Erreur de connexion au serveur");

    //Connexion a la base de donnee
    @mysql_select_db($database) OR DIE("Erreur de connexion &agrave; la base de donn&eacute;e");

    //suprimme bug accent
    @mysql_query("SET NAMES 'utf8'");

    //Selection de la table
    $query_news = "SELECT * FROM  " . $database . "." . $tb_news . " ORDER BY ID desc LIMIT 0, " . $limite . "";
    //Affichage de la selection  
    $result = @mysql_query($query_news) OR DIE("Erreur de la s&eacute;lection des news");

    //Selection de la table
    $query_annonce = "SELECT * FROM  " . $database . "." . $tb_info . "";
    //Affichage de la selection
    $result_annonce = @mysql_query($query_annonce) OR DIE("Erreur de la s&eacute;lection de l'annonce");
    $line_annonce = mysql_fetch_assoc($result_annonce);

    if ($line_annonce['annonce_choix_info'] == "Oui") {
        ?>
        <div id="box" onclick="document.getElementById('box').style.display='none';" class="info-box rounded" title="Fermer la fen&ecirc;tre">
            <?php echo $line_annonce['annonce_texte_info']; ?>
        </div>
        <br />
        <br />
        <?php
    }
    if (mysql_num_rows($result) == 0) {
        ?>
        <div id="box" onclick="document.getElementById('box').style.display='none';" class="info-box rounded" title="Fermer la fen&ecirc;tre">
            Aucune news n'a encore &eacute;t&eacute; r&eacute;dig&eacute;e.
        </div>
        <?php
    }
    while ($row = mysql_fetch_assoc($result)) {
        $id = $row['id'];
        $title = addChar(utf8_encode($row['title']));
        $author = utf8_decode($row['author']);
        $content = addChar(utf8_encode($row['content']));
        $date = convertDate($row['date']);
        require($template);
    }
}

function displayAllArchive() {
    require('./admin/connexion.php');

    $limite = 5;

    $template = "./news/templates/template_news_fr.php";
    //Connexion au serveur
    @mysql_connect($hostname, $username, $password) OR DIE("Erreur de connexion au serveur");

    //Connexion a la base de donnee
    @mysql_select_db($database) OR DIE("Erreur de connexion &agrave; la base de donn&eacute;e");

    //suprimme bug accent
    @mysql_query("SET NAMES 'utf8'");

    //Selection de la table
    $query_news = "SELECT * FROM  " . $database . "." . $tb_news . " ORDER BY ID desc";

    //Affichage de la selection
    $result = @mysql_query($query_news) OR DIE("Erreur de la s&eacute;lection des news");
    ?>
    <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
        <table>
            <tr>
                <td>
                    <?php
                    echo "\n\t\t<select name='mois'>";
                    for ($mois = 1; $mois <= 12; $mois++) {
                        if ($mois < 10) {
                            if ($mois < 10) {
                                echo " \n\t\t\t<OPTION selected value=$mois>0$mois</OPTION>";
                            } else {
                                echo " \n\t\t\t<OPTION selected value=$mois>$mois</OPTION>";
                            }
                        } else {
                            if ($mois < 10) {
                                echo "\n\t\t\t<OPTION value=$mois >0$mois</OPTION>";
                            } else {
                                echo "\n\t\t\t<OPTION value=$mois>$mois</OPTION>";
                            }
                        }
                    }
                    echo "\n\t\t</select></td><td>&nbsp;</td><td>";

                    echo "\n\t\t<select name='annee'>";
                    for ($annee = date('Y'); $annee <= 2020; $annee++) {
                        if ($annee < 10) {
                            echo "\n\t\t\t<OPTION selected value=$annee >$annee</OPTION>";
                        } else {
                            echo "\n\t\t\t<OPTION value=$annee>$annee</OPTION>";
                        }
                    }
                    echo "\n\t\t</select></td>";
                    ?>
                <td><input type="submit" name="valid_archive" value="OK" class="border" /></td>
            </tr>
        </table>
    </form>
    <br />
    <br />
    <br />
    <br />
    <?php
    if (isset($_POST['valid_archive'])) {
        ?>
        <div id="box" onclick="document.getElementById('box').style.display='none';" class="info-box rounded" title="Fermer la fen&ecirc;tre">
            Cette page est actuellement en cours de codage.
        </div>
        <br />
        <br />
        <?php
        $date_archive = $_POST['annee'] . "-" . $_POST['mois'] . "-00";
        //Selection de la table
        $query_news = "SELECT * FROM  " . $database . "." . $tb_news . " ORDER BY ID desc WHERE date = '$date_archive' ";
    } else {
        //Selection de la table
        $query_news = "SELECT * FROM  " . $database . "." . $tb_news . " ORDER BY ID desc";
    }
    if (mysql_num_rows($result) == 0) {
        ?>
        <div id="box" onclick="document.getElementById('box').style.display='none';" class="info-box rounded" title="Fermer la fen&ecirc;tre">
            Aucune news n'a encore &eacute;t&eacute; r&eacute;dig&eacute;e.
        </div>
        <?php
    }
    while ($row = mysql_fetch_assoc($result)) {
        $id = $row['id'];
        $title = addChar(utf8_encode($row['title']));
        $author = utf8_decode($row['author']);
        $content = addChar(utf8_encode($row['content']));
        $date = convertDate($row['date']);
        require($template);
    }
}

// Conversion de la date en jj/mm/aaaa
function convertDate($date) {
    $date_array = explode("-", $date);

    return $date_array[2] . "/" . $date_array[1] . "/" . $date_array[0];
}

function addChar($texte) {
    $texte = str_replace("^^", '<img src="./images/smileys/smiley1.png" alt="^^" title="^^" />', $texte);
    $texte = str_replace(";)", '<img src="./images/smileys/smiley2.png" alt=";)" title=";)" />', $texte);
    $texte = str_replace(":p", '<img src="./images/smileys/smiley3.png" alt=":p" title=":p" />', $texte);
    $texte = str_replace(":P", '<img src="./images/smileys/smiley3.png" alt=":P" title=":P" />', $texte);
    $texte = str_replace(":-°", '<img src="./images/smileys/smiley4.png" alt=":-°" title=":-°" />', $texte);
    $texte = str_replace(":gne:", '<img src="./images/smileys/smiley5.png" alt=":gne:" title=":gne:" />', $texte);
    $texte = str_replace("x_x", '<img src="./images/smileys/smiley6.png" alt="x_x" title="x_x" />', $texte);
    $texte = str_replace("x_X", '<img src="./images/smileys/smiley6.png" alt="x_X" title="x_X" />', $texte);
    $texte = str_replace("X_X", '<img src="./images/smileys/smiley6.png" alt="X_X" title="X_X" />', $texte);
    $texte = str_replace("o_o", '<img src="./images/smileys/smiley6.png" alt="o_o" title="o_o" />', $texte);
    $texte = str_replace("o_O", '<img src="./images/smileys/smiley6.png" alt="o_O" title="o_O" />', $texte);
    $texte = str_replace("O_O", '<img src="./images/smileys/smiley6.png" alt="O_O" title="O_O" />', $texte);
    $texte = str_replace(">_<", '<img src="./images/smileys/smiley6.png" alt=">_<" title=">_<" />', $texte);
    $texte = str_replace(":(", '<img src="./images/smileys/smiley7.png" alt=":(" title=":(" />', $texte);
    $texte = str_replace(":yeah:", '<img src="./images/smileys/smiley8.gif" alt=":yeah:" title=":yeah:" />', $texte);
    $texte = str_replace(":Yeah:", '<img src="./images/smileys/smiley8.gif" alt=":Yeah:" title=":Yeah:" />', $texte);
    $texte = str_replace(":YEAH:", '<img src="./images/smileys/smiley8.gif" alt=":YEAH:" title=":YEAH:" />', $texte);
    $texte = str_replace(":s", '<img src="./images/smileys/smiley9.gif" alt=":s" title=":s" />', $texte);
    $texte = str_replace(":S", '<img src="./images/smileys/smiley9.gif" alt=":S" title=":S" />', $texte);
    $texte = str_replace(":doute:", '<img src="./images/smileys/smiley10.gif" alt=":doute:" title=":doute:" />', $texte);
    $texte = str_replace(":ouch:", '<img src="./images/smileys/smiley11.gif" alt=":ouch:" title=":ouch:" />', $texte);
    $texte = str_replace(":)", '<img src="./images/smileys/smiley12.gif" alt=":)" title=":)" />', $texte);
    $texte = str_replace(":rire:", '<img src="./images/smileys/smiley13.gif" alt=":rire:" title=":rire:" />', $texte);
    $texte = str_replace(":-)", '<img src="./images/smileys/smiley14.gif" alt=":-)" title=":-)" />', $texte);
    $texte = str_replace(":ok:", '<img src="./images/smileys/smiley15.gif" alt=":ok:" title=":ok:" />', $texte);
    $texte = str_replace(":Ok:", '<img src="./images/smileys/smiley15.gif" alt=":Ok:" title=":Ok:" />', $texte);
    $texte = str_replace(":OK:", '<img src="./images/smileys/smiley15.gif" alt=":OK:" title=":OK:" />', $texte);
    $texte = str_replace(":up:", '<img src="./images/smileys/smiley16.gif" alt=":up:" title=":up:" />', $texte);
    $texte = str_replace(":Up:", '<img src="./images/smileys/smiley16.gif" alt=":Up:" title=":Up:" />', $texte);
    $texte = str_replace(":UP:", '<img src="./images/smileys/smiley16.gif" alt=":UP:" title=":UP:" />', $texte);
    $texte = str_replace(":hap:", '<img src="./images/smileys/smiley17.gif" alt=":hap:" title=":hap:" />', $texte);
    $texte = str_replace(":Hap:", '<img src="./images/smileys/smiley17.gif" alt=":Hap:" title=":Hap:" />', $texte);
    $texte = str_replace(":HAP:", '<img src="./images/smileys/smiley17.gif" alt=":HAP:" title=":HAP:" />', $texte);
    $texte = str_replace(":noel:", '<img src="./images/smileys/smiley18.gif" alt=":noel:" title=":noel:" />', $texte);
    $texte = str_replace(":Noel:", '<img src="./images/smileys/smiley18.gif" alt=":Noel:" title=":Noel:" />', $texte);
    $texte = str_replace(":NOEL:", '<img src="./images/smileys/smiley18.gif" alt=":NOEL:" title=":NOEL:" />', $texte);
    $texte = str_replace(":malade:", '<img src="./images/smileys/smiley19.gif" alt=":malade:" title=":malade:" />', $texte);
    $texte = str_replace(":Malade:", '<img src="./images/smileys/smiley19.gif" alt=":Malade:" title=":Malade:" />', $texte);
    $texte = str_replace(":MALADE:", '<img src="./images/smileys/smiley19.gif" alt=":MALADE:" title=":MALADE:" />', $texte);
    $texte = str_replace(":question:", '<img src="./images/smileys/smiley20.gif" alt=":question:" title=":question:" />', $texte);
    $texte = str_replace(":Question:", '<img src="./images/smileys/smiley20.gif" alt=":Question:" title=":Question:" />', $texte);
    $texte = str_replace(":QUESTION:", '<img src="./images/smileys/smiley20.gif" alt=":QUESTION:" title=":QUESTION:" />', $texte);
    $texte = str_replace(":coeur:", '<img src="./images/smileys/smiley21.gif" alt=":coeur:" title=":coeur:" />', $texte);
    $texte = str_replace(":Coeur:", '<img src="./images/smileys/smiley21.gif" alt=":Coeur:" title=":Coeur:" />', $texte);
    $texte = str_replace(":COEUR:", '<img src="./images/smileys/smiley21.gif" alt=":COEUR:" title=":COEUR:" />', $texte);
    $texte = str_replace(":bave:", '<img src="./images/smileys/smiley22.gif" alt=":bave:" title=":bave:" />', $texte);
    $texte = str_replace(":Bave:", '<img src="./images/smileys/smiley22.gif" alt=":Bave:" title=":Bave:" />', $texte);
    $texte = str_replace(":BAVE:", '<img src="./images/smileys/smiley22.gif" alt=":BAVE:" title=":BAVE:" />', $texte);
    $texte = str_replace("é", '&eacute;', $texte);
    $texte = str_replace("è", '&egrave;', $texte);
    $texte = str_replace("ê", '&ecirc;', $texte);
    $texte = str_replace("à", '&agrave;', $texte);
    $texte = str_replace("â", '&acirc;', $texte);
    $texte = str_replace("ô", '&ocirc;', $texte);
    $texte = str_replace("û", '&ucirc;', $texte);
    $texte = str_replace("ù", '&ugrave;', $texte);
    $texte = str_replace("î", '&icirc;', $texte);
    $texte = str_replace("ü", '&uuml;', $texte);
    $texte = str_replace("ï", '&iuml;', $texte);
    $texte = str_replace("ö", '&ouml;', $texte);
    $texte = str_replace("ç", '&ccedil;', $texte);
    $texte = str_replace("É", '&Eacute;', $texte);
    $texte = str_replace("È", '&Egrave;', $texte);
    $texte = str_replace("Ê", '&Ecirc;', $texte);
    $texte = str_replace("À", '&Agrave;', $texte);
    $texte = str_replace("À", '&Acirc;', $texte);
    $texte = str_replace("Ô", '&Ocirc;', $texte);
    $texte = str_replace("Û", '&Ucirc;', $texte);
    $texte = str_replace("Ù", '&Ugrave;', $texte);
    $texte = str_replace("Î", '&Icirc;', $texte);
    $texte = str_replace("Ü", '&Uuml;', $texte);
    $texte = str_replace("Ï", '&Iuml;', $texte);
    $texte = str_replace("Ö", '&Ouml;', $texte);
    $texte = str_replace("Ç", '&Ccedil;', $texte);
    $texte = str_replace("&", '&amp;', $texte);
    $texte = preg_replace('#\[b\](.+)\[/b\]#isU', '<strong>$1</strong>', $texte);
    $texte = preg_replace('#\[i\](.+)\[/i\]#isU', '<em>$1</em>', $texte);
    $texte = preg_replace('#\[u\](.+)\[/u\]#isU', '<u>$1</u>', $texte);
    $texte = preg_replace('#\[cmd\](.+)\[/cmd\]#isU', '<b class=\"cmd\">$1</b>', $texte);
    $texte = preg_replace('#\[lien\](.+)\[/lien\]#isU', '<u><b>$1</b></u>', $texte);
    $texte = preg_replace('#\[color=(red|green|blue|yellow|purple|olive)\](.+)\[/color\]#isU', '<span style="color:$1">$2</span>', $texte);
    $texte = preg_replace('#http://[a-z0-9._/-]+#i', '<a href="$0">$0</a>', $texte);
    return utf8_decode($texte);
}

function addChar_admin($texte) {
    $texte = str_replace("^^", '<img src="../images/smileys/smiley1.png" alt="^^" title="^^" />', $texte);
    $texte = str_replace(";)", '<img src="../images/smileys/smiley2.png" alt=";)" title=";)" />', $texte);
    $texte = str_replace(":p", '<img src="../images/smileys/smiley3.png" alt=":p" title=":p" />', $texte);
    $texte = str_replace(":P", '<img src="../images/smileys/smiley3.png" alt=":P" title=":P" />', $texte);
    $texte = str_replace(":-°", '<img src="../images/smileys/smiley4.png" alt=":-°" title=":-°" />', $texte);
    $texte = str_replace(":gne:", '<img src="../images/smileys/smiley5.png" alt=":gne:" title=":gne:" />', $texte);
    $texte = str_replace("x_x", '<img src="../images/smileys/smiley6.png" alt="x_x" title="x_x" />', $texte);
    $texte = str_replace("x_X", '<img src="../images/smileys/smiley6.png" alt="x_X" title="x_X" />', $texte);
    $texte = str_replace("X_X", '<img src="../images/smileys/smiley6.png" alt="X_X" title="X_X" />', $texte);
    $texte = str_replace("o_o", '<img src="../images/smileys/smiley6.png" alt="o_o" title="o_o" />', $texte);
    $texte = str_replace("o_O", '<img src="../images/smileys/smiley6.png" alt="o_O" title="o_O" />', $texte);
    $texte = str_replace("O_O", '<img src="../images/smileys/smiley6.png" alt="O_O" title="O_O" />', $texte);
    $texte = str_replace(">_<", '<img src="../images/smileys/smiley6.png" alt=">_<" title=">_<" />', $texte);
    $texte = str_replace(":(", '<img src="../images/smileys/smiley7.png" alt=":(" title=":(" />', $texte);
    $texte = str_replace(":yeah:", '<img src="../images/smileys/smiley8.gif" alt=":yeah:" title=":yeah:" />', $texte);
    $texte = str_replace(":Yeah:", '<img src="../images/smileys/smiley8.gif" alt=":Yeah:" title=":Yeah:" />', $texte);
    $texte = str_replace(":YEAH:", '<img src="../images/smileys/smiley8.gif" alt=":YEAH:" title=":YEAH:" />', $texte);
    $texte = str_replace(":s", '<img src="../images/smileys/smiley9.gif" alt=":s" title=":s" />', $texte);
    $texte = str_replace(":S", '<img src="../images/smileys/smiley9.gif" alt=":S" title=":S" />', $texte);
    $texte = str_replace(":doute:", '<img src="../images/smileys/smiley10.gif" alt=":doute:" title=":doute:" />', $texte);
    $texte = str_replace(":ouch:", '<img src="../images/smileys/smiley11.gif" alt=":ouch:" title=":ouch:" />', $texte);
    $texte = str_replace(":)", '<img src="../images/smileys/smiley12.gif" alt=":)" title=":)" />', $texte);
    $texte = str_replace(":rire:", '<img src="../images/smileys/smiley13.gif" alt=":rire:" title=":rire:" />', $texte);
    $texte = str_replace(":-)", '<img src="../images/smileys/smiley14.gif" alt=":-)" title=":-)" />', $texte);
    $texte = str_replace(":ok:", '<img src="../images/smileys/smiley15.gif" alt=":ok:" title=":ok:" />', $texte);
    $texte = str_replace(":Ok:", '<img src="../images/smileys/smiley15.gif" alt=":Ok:" title=":Ok:" />', $texte);
    $texte = str_replace(":OK:", '<img src="../images/smileys/smiley15.gif" alt=":OK:" title=":OK:" />', $texte);
    $texte = str_replace(":up:", '<img src="../images/smileys/smiley16.gif" alt=":up:" title=":up:" />', $texte);
    $texte = str_replace(":Up:", '<img src="../images/smileys/smiley16.gif" alt=":Up:" title=":Up:" />', $texte);
    $texte = str_replace(":UP:", '<img src="../images/smileys/smiley16.gif" alt=":UP:" title=":UP:" />', $texte);
    $texte = str_replace(":hap:", '<img src="../images/smileys/smiley17.gif" alt=":hap:" title=":hap:" />', $texte);
    $texte = str_replace(":Hap:", '<img src="../images/smileys/smiley17.gif" alt=":Hap:" title=":Hap:" />', $texte);
    $texte = str_replace(":HAP:", '<img src="../images/smileys/smiley17.gif" alt=":HAP:" title=":HAP:" />', $texte);
    $texte = str_replace(":noel:", '<img src="../images/smileys/smiley18.gif" alt=":noel:" title=":noel:" />', $texte);
    $texte = str_replace(":Noel:", '<img src="../images/smileys/smiley18.gif" alt=":Noel:" title=":Noel:" />', $texte);
    $texte = str_replace(":NOEL:", '<img src="../images/smileys/smiley18.gif" alt=":NOEL:" title=":NOEL:" />', $texte);
    $texte = str_replace(":malade:", '<img src="../images/smileys/smiley19.gif" alt=":malade:" title=":malade:" />', $texte);
    $texte = str_replace(":Malade:", '<img src="../images/smileys/smiley19.gif" alt=":Malade:" title=":Malade:" />', $texte);
    $texte = str_replace(":MALADE:", '<img src="../images/smileys/smiley19.gif" alt=":MALADE:" title=":MALADE:" />', $texte);
    $texte = str_replace(":question:", '<img src="../images/smileys/smiley20.gif" alt=":question:" title=":question:" />', $texte);
    $texte = str_replace(":Question:", '<img src="../images/smileys/smiley20.gif" alt=":Question:" title=":Question:" />', $texte);
    $texte = str_replace(":QUESTION:", '<img src="../images/smileys/smiley20.gif" alt=":QUESTION:" title=":QUESTION:" />', $texte);
    $texte = str_replace(":coeur:", '<img src="../images/smileys/smiley21.gif" alt=":coeur:" title=":coeur:" />', $texte);
    $texte = str_replace(":Coeur:", '<img src="../images/smileys/smiley21.gif" alt=":Coeur:" title=":Coeur:" />', $texte);
    $texte = str_replace(":COEUR:", '<img src="../images/smileys/smiley21.gif" alt=":COEUR:" title=":COEUR:" />', $texte);
    $texte = str_replace(":bave:", '<img src="../images/smileys/smiley22.gif" alt=":bave:" title=":bave:" />', $texte);
    $texte = str_replace(":Bave:", '<img src="../images/smileys/smiley22.gif" alt=":Bave:" title=":Bave:" />', $texte);
    $texte = str_replace(":BAVE:", '<img src="../images/smileys/smiley22.gif" alt=":BAVE:" title=":BAVE:" />', $texte);
    $texte = str_replace("é", '&eacute;', $texte);
    $texte = str_replace("è", '&egrave;', $texte);
    $texte = str_replace("ê", '&ecirc;', $texte);
    $texte = str_replace("à", '&agrave;', $texte);
    $texte = str_replace("â", '&acirc;', $texte);
    $texte = str_replace("ô", '&ocirc;', $texte);
    $texte = str_replace("û", '&ucirc;', $texte);
    $texte = str_replace("ù", '&ugrave;', $texte);
    $texte = str_replace("î", '&icirc;', $texte);
    $texte = str_replace("ü", '&uuml;', $texte);
    $texte = str_replace("ï", '&iuml;', $texte);
    $texte = str_replace("ö", '&ouml;', $texte);
    $texte = str_replace("ç", '&ccedil;', $texte);
    $texte = str_replace("É", '&Eacute;', $texte);
    $texte = str_replace("È", '&Egrave;', $texte);
    $texte = str_replace("Ê", '&Ecirc;', $texte);
    $texte = str_replace("À", '&Agrave;', $texte);
    $texte = str_replace("À", '&Acirc;', $texte);
    $texte = str_replace("Ô", '&Ocirc;', $texte);
    $texte = str_replace("Û", '&Ucirc;', $texte);
    $texte = str_replace("Ù", '&Ugrave;', $texte);
    $texte = str_replace("Î", '&Icirc;', $texte);
    $texte = str_replace("Ü", '&Uuml;', $texte);
    $texte = str_replace("Ï", '&Iuml;', $texte);
    $texte = str_replace("Ö", '&Ouml;', $texte);
    $texte = str_replace("Ç", '&Ccedil;', $texte);
    $texte = str_replace("&", '&amp;', $texte);
    $texte = preg_replace('#\[b\](.+)\[/b\]#isU', '<strong>$1</strong>', $texte);
    $texte = preg_replace('#\[i\](.+)\[/i\]#isU', '<em>$1</em>', $texte);
    $texte = preg_replace('#\[u\](.+)\[/u\]#isU', '<u>$1</u>', $texte);
    $texte = preg_replace('#\[cmd\](.+)\[/cmd\]#isU', '<b class=\"cmd\">$1</b>', $texte);
    $texte = preg_replace('#\[lien\](.+)\[/lien\]#isU', '<u><b>$1</b></u>', $texte);
    $texte = preg_replace('#\[color=(red|green|blue|yellow|purple|olive)\](.+)\[/color\]#isU', '<span style="color:$1">$2</span>', $texte);
    $texte = preg_replace('#http://[a-z0-9._/-]+#i', '<a href="$0">$0</a>', $texte);
    return utf8_decode($texte);
}

function show_user_profil() {
    require('./admin/connexion.php');
    $query = "SELECT * FROM " . $database . "." . $tb_plugins . "";
    $result = @mysql_query($query) OR DIE("Erreur de la s&eacute;lection des plugins : " . mysql_error());
    $line = mysql_fetch_assoc($result);
    $iconomy = $line['iconomy_plg'];
    $jobs = $line['jobs_plg'];
    ?>
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
        <table border="0" cellspacing="0">
            <tr>
                <td colspan="3" class="title_form">Vos informations</td>
            </tr>
            <tr>
                <td class="text_form">Pr&eacute;nom : </td>
                <td><?php echo addChar(utf8_encode($_SESSION['prenom'])); ?></td>
            </tr>
            <tr>
                <td class="text_form">Nom : </td>
                <td><?php echo addChar(utf8_encode($_SESSION['nom'])); ?></td>
            </tr>                        
            <tr>
                <td class="text_form">Adresse e-mail : </td>
                <td><?php echo $_SESSION['email']; ?></td>
            </tr>
            <tr>
                <td class="text_form">Skype : </td>
                <td><input type="text" name="skype" size="30" value="<?php echo $_SESSION['skype']; ?>" class="border" /></td>
            </tr>
            <tr>
                <td colspan="3" class="title_form">Votre profil</td>
            </tr>
            <tr>
                <td class="text_form">Pseudo : </td>
                <td><?php echo utf8_decode($_SESSION['login']); ?></td>
            </tr>
            <tr>
                <td class="text_form">Mot de passe actuel :</td>
                <td><input type="password" name="pass_old" size="30" value="" class="border" /></td>
            </tr>
            <tr>
                <td class="text_form">Nouveau mot de passe : </td>
                <td><input type="password" name="pass" size="30" value="" class="border" /></td>
            </tr>
            <tr>
                <td class="text_form">R&eacute;p&eacute;tez le mot de passe : </td>
                <td><input type="password" name="pass2" size="30" value="" class="border" /></td>
            </tr>
        </table>
        <br />
        <input type="submit" name="edit_profil" value="Modifier" class="btn" />
        <?php
        if ($iconomy == "Oui") {
            ?>
            <a href="./iconomy.php" class="btn" title="G&eacute;rer mon compte iConomy">Mon solde</a>
            <?php
        }
        if ($jobs == "Oui") {
            ?>
            <a href="./jobs.php" class="btn" title="Consulter mes Jobs">Mes Jobs</a>
            <?php
        }
        ?>
        <br />
    </form>
    <?php
}

function show_mp_box() {
    require('./admin/connexion.php');

    $login = $_SESSION['login'];
    //Selection de la table
    $query_usr = "SELECT * FROM " . $database . "." . $tb_mp . " WHERE pseudo_mp = '$login' OR from_mp = '$login' ";
    //Affichage de la selection
    $result_usr = @mysql_query($query_usr) OR DIE("Erreur de la s&eacute;lection des utilisateurs : " . mysql_error());

    //Selection de la table
    $query_user = "SELECT * FROM " . $database . "." . $tb_utilisateurs . " ";
    //Affichage de la selection
    $result_user = @mysql_query($query_user) OR DIE("Erreur de la s&eacute;lection des utilisateurs : " . mysql_error());
    ?>
    <table class="mp">
        <thead>
            <tr>
                <td class="title_form_little" >Exp&eacute;diteur</td><td class="title_form_little" >R&eacute;ceptionneur</td><td class="title_form">Sujet</td>
            </tr>
        </thead>
        <tbody>
            <?php
            if (mysql_num_rows($result_usr) == 0) {
                ?>
                <tr>
                    <td class="text_form" colspan="3">Vous n'avez aucun message...</td>
                </tr>
                <?php
            } else {
                while ($usr = mysql_fetch_assoc($result_usr)) {
                    ?>
                    <tr class="mp_hover">
                        <td class="text_form_little"><a href="./user.php?user=<?php echo $usr['from_mp']; ?>" title="Voir le profil de <?php echo $usr['from_mp']; ?>"><?php echo $usr['from_mp']; ?></a></td>
                        <td class="text_form_little"><a href="./user.php?user=<?php echo $usr['to_mp']; ?>" title="Voir le profil de <?php echo $usr['to_mp']; ?>"><?php echo $usr['to_mp']; ?></a></td>
                        <td class="text_form"><form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"><input type="submit" class="mp_title left" title="Lire le message de <?php echo $usr['from_mp']; ?>" value="<?php echo $usr['title_mp']; ?>" /><?php echo "<input type=\"hidden\" name=\"message_id\" value=\"" . $usr ['id_mp'] . "\">" ?></form><?php echo "<form method=\"post\" action=\"./message.php?action=delete\" ><input type=\"hidden\" name=\"del_id\" value=\"" . $usr ['id_mp'] . "\"><input type='image' src=\"./images/icone/delete_little.png\" name='del_mp' value='Supprimer' alt='Supprimer' title='Supprimer' class='right'></form>"; ?></td>
                    </tr>
                    <?php
                }
            }
            ?>      
        </tbody>
        <tfoot>
            <tr>
                <td colspan="3" valign="middle" align="center">
                    <br />
                    <a href="./message.php?action=new" class="btn">Nouveau message</a> <br />
                    <br />
                </td>
            </tr>
        </tfoot>
    </table>
    <br />
    <?php
}

function show_maintenance() {
    require('./admin/connexion.php');
    $query_info = "SELECT * FROM  " . $database . "." . $tb_info . "";
    $result_info = @mysql_query($query_info) OR DIE("Erreur de la s&eacute;lection des informations");
    $line_info = mysql_fetch_assoc($result_info);

    $site = $line_info['sitename_info'];
    $facebook = $line_info['facebook_info'];
    ?>
    <title><?php echo $site; ?> | Maintenance</title>
    <link rel="stylesheet" type="text/css" href="./css/style.css" title="" media="all" />
    <div class="maintenance rounded">
        <center>
            <img src="./images/structure/logo.png" /> <br />
            <br />
            Le site est actuellement en maintenance. Si vous avez une question, vous pouvez contacter l'administrateur via le serveur. <br />
            <br />
            <h3>Raison(s) de la maintenance</h3>
            <b><?php echo $line_info['maintenance_texte_info']; ?></b> <br />
            <br />
            <hr />
            <br />
            <center><b>[ <a href="./admin/">Panneau d'Administration</a> ]</b></center>
        </center>
    </div>
    <div class="wrapper">
        <div class="footer">
            <div class="left content">
                <span class="ltr">&copy; <a href="./admin/" class="tooltip" title="Tous Droits R&eacute;serv&eacute;s"><?php echo $site; ?></a> | 2011 | <a href="http://www.facebook.com/pages/Fujido/129154603839560" title="Page Facebook">Fujido</a></span>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <?php
}
?>